package xonmp.notepaddemo.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class NotepadDbHelper extends SQLiteOpenHelper {

	private static final String TAG = "NotepadDbHelper";
	public static final String DATABASE_NAME = "notepad_demo";
	private static final int DATABASE_VERSION = 1;
	public static final String DATABASE_TABLE = "notepad";
	private static final String DATABASE_CREATE = "create table notepad"
			+ "(_id integer primary key autoincrement, "
			+ "title text not null, "
			+ "body text not null);";
	
	public NotepadDbHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DATABASE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
				+ newVersion + ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS notepad");
		onCreate(db);		
	}


}
